package com.hd.openapi.servies.serviceimpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hd.openapi.common.ResponseResult;
import com.hd.openapi.common.ResultTable;
import com.hd.openapi.dao.CustomerMapper;
import com.hd.openapi.dao.RechargeMapper;
import com.hd.openapi.entity.Customer;
import com.hd.openapi.entity.Recharge;
import com.hd.openapi.servies.rechargeser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class rechargeserIMPL implements rechargeser {
    @Autowired
    private RechargeMapper rg;
    @Autowired
    private CustomerMapper cm;


    @Override
    public ResultTable getalldata(Integer page, Integer limit) {
        PageHelper.startPage (page,limit);
        List<Recharge> a=rg.getdata();
        PageInfo aa=new PageInfo (a);
        return new ResultTable (0,"",(int)aa.getTotal (),aa.getList ());
    }

    @Override
    public ResponseResult deldat(Integer[] ids) {
        int i =rg.del(ids);
        return ResponseResult.getSuccess ();
    }

    @Override
    public List<Customer> getall() {
        List<Customer> a = cm.getall();
        return a;
    }

    @Override
    public ResponseResult adddata(Recharge recharge) {
        int i = rg.insertSelective (recharge);
        return ResponseResult.getSuccess ();
    }

    @Override
    public ResponseResult updatada(Recharge recharge) {
        int i=rg.updateByPrimaryKeySelective (recharge);
        return ResponseResult.getSuccess ();
    }
}
